package com.tailyou.androidlearning202400.act

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.tailyou.androidlearning202400.R
import com.tailyou.androidlearning202400.adapter.AdapterChat
import com.tailyou.androidlearning202400.beans.ChatBean

class WeChatActivity : AppCompatActivity() {

    private lateinit var rvChat: RecyclerView

    // 存放数据的集合
    private var mData = mutableListOf<ChatBean>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        this.enableEdgeToEdge()
        setContentView(R.layout.activity_we_chat)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v: View, insets: WindowInsetsCompat ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        rvChat = findViewById(R.id.rvChat)
        mData.add(ChatBean(R.mipmap.msg2, "互联网基础—开发23级", "颜健:[综合实训]", "12-13"))
        mData.add(ChatBean(R.mipmap.msg3, "小通活动助手", "这是来自官方的消息", "09:15"))
        mData.add(ChatBean(R.mipmap.msg4, "心理健康教育（三）", "这是来自官方的消息", "09:15"))
        mData.add(ChatBean(R.mipmap.msg5, "2024-2025学年形势与政策", "这是来自官方的消息", "09:15"))
        mData.add(ChatBean(R.mipmap.msg6, "鸿蒙应用开发基础", "这是来自官方的消息", "09:15"))
        mData.add(ChatBean(R.mipmap.msg7, "2023级劳动教育（二）", "这是来自官方的消息", "09:15"))
        rvChat.layoutManager = LinearLayoutManager(this)
        val adapterChat = AdapterChat(mData)
        rvChat.adapter = adapterChat
    }

}